package com.java110.mall.goods.smo.impl;


import com.java110.dto.housekeeping.HousekeepingTypeDto;
import com.java110.intf.goods.IHousekeepingTypeInnerServiceSMO;
import com.java110.mall.goods.dao.IHousekeepingTypeServiceDao;
import com.java110.po.housekeeping.HousekeepingTypePo;
import com.java110.utils.util.BeanConvertUtil;
import com.java110.core.base.smo.BaseServiceSMO;
import com.java110.dto.PageDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName FloorInnerServiceSMOImpl
 * @Description 家政服务类型内部服务实现类
 * @Author wuxw
 * @Date 2019/4/24 9:20
 * @Version 1.0
 * add by wuxw 2019/4/24
 **/
@RestController
public class HousekeepingTypeInnerServiceSMOImpl extends BaseServiceSMO implements IHousekeepingTypeInnerServiceSMO {

    @Autowired
    private IHousekeepingTypeServiceDao housekeepingTypeServiceDaoImpl;


    @Override
    public int saveHousekeepingType(@RequestBody HousekeepingTypePo housekeepingTypePo) {
        int saveFlag = 1;
        housekeepingTypeServiceDaoImpl.saveHousekeepingTypeInfo(BeanConvertUtil.beanCovertMap(housekeepingTypePo));
        return saveFlag;
    }

     @Override
    public int updateHousekeepingType(@RequestBody  HousekeepingTypePo housekeepingTypePo) {
        int saveFlag = 1;
         housekeepingTypeServiceDaoImpl.updateHousekeepingTypeInfo(BeanConvertUtil.beanCovertMap(housekeepingTypePo));
        return saveFlag;
    }

     @Override
    public int deleteHousekeepingType(@RequestBody  HousekeepingTypePo housekeepingTypePo) {
        int saveFlag = 1;
        housekeepingTypePo.setStatusCd("1");
        housekeepingTypeServiceDaoImpl.updateHousekeepingTypeInfo(BeanConvertUtil.beanCovertMap(housekeepingTypePo));
        return saveFlag;
    }

    @Override
    public List<HousekeepingTypeDto> queryHousekeepingTypes(@RequestBody  HousekeepingTypeDto housekeepingTypeDto) {

        //校验是否传了 分页信息

        int page = housekeepingTypeDto.getPage();

        if (page != PageDto.DEFAULT_PAGE) {
            housekeepingTypeDto.setPage((page - 1) * housekeepingTypeDto.getRow());
        }

        List<HousekeepingTypeDto> housekeepingTypes = BeanConvertUtil.covertBeanList(housekeepingTypeServiceDaoImpl.getHousekeepingTypeInfo(BeanConvertUtil.beanCovertMap(housekeepingTypeDto)), HousekeepingTypeDto.class);

        return housekeepingTypes;
    }


    @Override
    public int queryHousekeepingTypesCount(@RequestBody HousekeepingTypeDto housekeepingTypeDto) {
        return housekeepingTypeServiceDaoImpl.queryHousekeepingTypesCount(BeanConvertUtil.beanCovertMap(housekeepingTypeDto));    }

    public IHousekeepingTypeServiceDao getHousekeepingTypeServiceDaoImpl() {
        return housekeepingTypeServiceDaoImpl;
    }

    public void setHousekeepingTypeServiceDaoImpl(IHousekeepingTypeServiceDao housekeepingTypeServiceDaoImpl) {
        this.housekeepingTypeServiceDaoImpl = housekeepingTypeServiceDaoImpl;
    }
}
